-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(operators): add mapResponse
#4302
Conversation
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @tom9744! In addition to the suggested changes, can you please add the mapResponse
section to this page: https://ngrx.io/guide/operators/operators
It should contain the description and example of using the mapResponse
operator. The example can be an NgRx effect + mapResponse
.
I appreciate your kind feedback on my work, @markostanimirovic! I modified the code based on your suggestions, and am currently working on writing a document for ngrx.io. |
error: (error: E) => R2; | ||
type MapResponseObserver<T, S, E> = { | ||
next: (value: T) => S; | ||
error: (error: unknown) => E; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would make more sense to type error
as unknown
because we don't know what type the error
can possibly be in various use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change. When error
is explicitly set to unknown
, it's not possible to override its type:
mapResponse({
next: (val) => val + 1,
error: (err: { message: string }) => err, // compilation error
})
This should be allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tom9744! Few small suggestions 👇
error: (error: E) => R2; | ||
type MapResponseObserver<T, S, E> = { | ||
next: (value: T) => S; | ||
error: (error: unknown) => E; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change. When error
is explicitly set to unknown
, it's not possible to override its type:
mapResponse({
next: (val) => val + 1,
error: (err: { message: string }) => err, // compilation error
})
This should be allowed.
I understood that typing the |
aeb4bdf
to
f09ef97
Compare
This reverts commit 8142313.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
mapResponse
#4230mapResponse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@markostanimirovic do you think we should also add a JSDoc (with usagenotes) as we do with the other operators?
Good point Tim! I created an issue for this: #4336 |
PR Checklist
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closes #4230
What is the new behavior?
Does this PR introduce a breaking change?
Other information
I am not 100% sure if I correctly understood the expected behavior of
mapResponse
, as @markostanimirovic suggested in #4230.Please feel free to give me feedback.
Thanks.